﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CRM.UTIL;
using System.Data.SqlClient;

namespace CRM.DAL.Role
{
    public class UsersD : DBChannel
    {

        #region 执行存储过程 Pro_GetUsers ,根据条件获取回馈信息
        /// <summary>
        /// 执行存储过程 Pro_GetUsers 
        ///向国祥
        /// </summary>

        public DataTable ExecuteGetUsers(ref CRM.MODEL.GetUsers stu)
        {
            //存储过程参数	 		     
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.DEPTID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.COMPID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ISDEL_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ISADMIN_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.FULLNAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.LOGINNAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ABRIDGENAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.PASSWORD_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.RESIDENTID_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.BIRTHDAY_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.MOBILEPHONEID_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.MOBILEPHONE_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.GENDER_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.DOMICILEPLACE_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.EDUCATION_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.EMAIL_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.CREATEBY_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.CREATETIME_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.LASTMODIFYBY_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.LASTMODIFYTIME_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.QQ_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.REMARK_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ISACTIVE_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP1_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP2_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP3_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP4_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP5_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP6_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP7_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TEMP8_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.KEYVALUE_PARM, SqlDbType.NVarChar));

            //分页参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.ORDERSTRING_PARM, SqlDbType.VarChar, 1000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.PAGESIZE_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.CURRENTPAGEINDEX_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.GetUsers.TOTALITEMS_PARM, SqlDbType.Decimal));

            //设置参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ID_PARM].Value = stu.ID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.DEPTID_PARM].Value = stu.DEPTID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.COMPID_PARM].Value = stu.COMPID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ISDEL_PARM].Value = stu.ISDEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ISADMIN_PARM].Value = stu.ISADMIN_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.FULLNAME_PARM].Value = stu.FULLNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.LOGINNAME_PARM].Value = stu.LOGINNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ABRIDGENAME_PARM].Value = stu.ABRIDGENAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.PASSWORD_PARM].Value = stu.PASSWORD_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.RESIDENTID_PARM].Value = stu.RESIDENTID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.BIRTHDAY_PARM].Value = stu.BIRTHDAY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.MOBILEPHONEID_PARM].Value = stu.MOBILEPHONEID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.MOBILEPHONE_PARM].Value = stu.MOBILEPHONE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.GENDER_PARM].Value = stu.GENDER_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.DOMICILEPLACE_PARM].Value = stu.DOMICILEPLACE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.EDUCATION_PARM].Value = stu.EDUCATION_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.EMAIL_PARM].Value = stu.EMAIL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.CREATEBY_PARM].Value = stu.CREATEBY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.CREATETIME_PARM].Value = stu.CREATETIME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.LASTMODIFYBY_PARM].Value = stu.LASTMODIFYBY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.LASTMODIFYTIME_PARM].Value = stu.LASTMODIFYTIME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.QQ_PARM].Value = stu.QQ_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.REMARK_PARM].Value = stu.REMARK_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ISACTIVE_PARM].Value = stu.ISACTIVE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP1_PARM].Value = stu.TEMP1_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP2_PARM].Value = stu.TEMP2_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP3_PARM].Value = stu.TEMP3_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP4_PARM].Value = stu.TEMP4_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP5_PARM].Value = stu.TEMP5_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP6_PARM].Value = stu.TEMP6_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP7_PARM].Value = stu.TEMP7_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TEMP8_PARM].Value = stu.TEMP8_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.KEYVALUE_PARM].Value = stu.KEYVALUE_VALUE;

            //设置分页参数的值
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.ORDERSTRING_PARM].Value = stu.ORDERSTRING_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.PAGESIZE_PARM].Value = stu.PAGESIZE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.CURRENTPAGEINDEX_PARM].Value = stu.CURRENTPAGEINDEX_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TOTALITEMS_PARM].Value = stu.TOTALITEMS_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TOTALITEMS_PARM].Direction = ParameterDirection.Output;

            //执行
            DataTable dt = this.GetDataByProcedure("dbo.Pro_GetUsers");
            //获取数据库的信息
            stu.TOTALITEMS_VALUE = this.sqlCmd.Parameters[CRM.MODEL.GetUsers.TOTALITEMS_PARM].Value;

            return dt;
        }
        #endregion







        #region 执行存储过程 Pro_EditUsers,根据条件获取回馈信息
        /// <summary>
        /// 执行存储过程 Pro_EditUsers 的相关参数
        ///向国祥
        /// </summary>

        public int ExecuteEditUsers(ref CRM.MODEL.EditUsers stu)
        {
            //动作参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ACTION_PARM, SqlDbType.VarChar, 20));
            //错误信息参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ERRMSG_PARM, SqlDbType.VarChar, 100));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.OUTID_PARM, SqlDbType.Int));
            ////表字段参数
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.DEPTID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.COMPID_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ISDEL_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ISADMIN_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.FULLNAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.LOGINNAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ABRIDGENAME_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.PASSWORD_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.RESIDENTID_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.BIRTHDAY_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.MOBILEPHONEID_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.MOBILEPHONE_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.GENDER_PARM, SqlDbType.Int));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.DOMICILEPLACE_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.EDUCATION_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.EMAIL_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.CREATEBY_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.CREATETIME_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.LASTMODIFYBY_PARM, SqlDbType.NVarChar, 500));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.LASTMODIFYTIME_PARM, SqlDbType.DateTime));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.QQ_PARM, SqlDbType.NVarChar, 50));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.REMARK_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.ISACTIVE_PARM, SqlDbType.Char, 1));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP1_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP2_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP3_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP4_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP5_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP6_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP7_PARM, SqlDbType.NVarChar, 2000));
            this.sqlCmd.Parameters.Add(new SqlParameter(CRM.MODEL.EditUsers.TEMP8_PARM, SqlDbType.NVarChar, 2000));



            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ACTION_PARM].Value = stu.ACTION_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ERRMSG_PARM].Direction = ParameterDirection.Output;

            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.OUTID_PARM].Direction = ParameterDirection.Output;
            //设置参数的值
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ID_PARM].Value = stu.ID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.DEPTID_PARM].Value = stu.DEPTID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.COMPID_PARM].Value = stu.COMPID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ISDEL_PARM].Value = stu.ISDEL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ISADMIN_PARM].Value = stu.ISADMIN_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.FULLNAME_PARM].Value = stu.FULLNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.LOGINNAME_PARM].Value = stu.LOGINNAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ABRIDGENAME_PARM].Value = stu.ABRIDGENAME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.PASSWORD_PARM].Value = stu.PASSWORD_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.RESIDENTID_PARM].Value = stu.RESIDENTID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.BIRTHDAY_PARM].Value = stu.BIRTHDAY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.MOBILEPHONEID_PARM].Value = stu.MOBILEPHONEID_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.MOBILEPHONE_PARM].Value = stu.MOBILEPHONE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.GENDER_PARM].Value = stu.GENDER_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.DOMICILEPLACE_PARM].Value = stu.DOMICILEPLACE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.EDUCATION_PARM].Value = stu.EDUCATION_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.EMAIL_PARM].Value = stu.EMAIL_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.CREATEBY_PARM].Value = stu.CREATEBY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.CREATETIME_PARM].Value = stu.CREATETIME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.LASTMODIFYBY_PARM].Value = stu.LASTMODIFYBY_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.LASTMODIFYTIME_PARM].Value = stu.LASTMODIFYTIME_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.QQ_PARM].Value = stu.QQ_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.REMARK_PARM].Value = stu.REMARK_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ISACTIVE_PARM].Value = stu.ISACTIVE_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP1_PARM].Value = stu.TEMP1_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP2_PARM].Value = stu.TEMP2_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP3_PARM].Value = stu.TEMP3_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP4_PARM].Value = stu.TEMP4_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP5_PARM].Value = stu.TEMP5_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP6_PARM].Value = stu.TEMP6_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP7_PARM].Value = stu.TEMP7_VALUE;
            this.sqlCmd.Parameters[CRM.MODEL.EditUsers.TEMP8_PARM].Value = stu.TEMP8_VALUE;

            int i = this.ExecuteProcedure("dbo.Pro_EditUsers");//执行	
            //获取数据库的信息
            stu.ERRMSG_VALUE = this.sqlCmd.Parameters[CRM.MODEL.EditUsers.ERRMSG_PARM].Value;
            return i;
        }
        #endregion
    }
}
